package com.lby.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName FanoutBindConfig
 * @Description TODO rabbit广播模式
 * @Author louby0923
 * @Date 2024/2/2 9:38
 * @Version 1.0
 */
@Configuration
public class FanoutBindConfig {

    /**
     * 交换机
     *
     * @return
     */
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("lby.fanout");
    }

    // 队列1
    @Bean
    public Queue queue1() {
        return new Queue("lby.fanout.queue1");
    }

    // 队列1
    @Bean
    public Queue queue2() {
        return new Queue("lby.fanout.queue2");
    }

    // 绑定交换机
    @Bean
    public Binding binding1() {
        return BindingBuilder.bind(queue1()).to(fanoutExchange());
    }

    @Bean
    public Binding binding2() {
        return BindingBuilder.bind(queue2()).to(fanoutExchange());
    }
}
